import * as THREE from "three";
import { Shape, ShapeParams } from "./Shape";

interface SphereParams {
    radius:number
    speed:number
}
export class SphereShape extends Shape {
    getRandomPosition(): THREE.Vector3 {
        const radius = this.params.radius || 1;
        const theta = Math.random() * Math.PI * 2;
        const phi = Math.acos(2 * Math.random() - 1);
        
        const x = radius * Math.sin(phi) * Math.cos(theta);
        const y = radius * Math.sin(phi) * Math.sin(theta);
        const z = radius * Math.cos(phi);
        
        return new THREE.Vector3(x, y, z).add(this.origin);
    }
    getNormal(p:THREE.Vector3){
        return p.clone().sub( this.origin).normalize();
    }

    getRandomNormal(): THREE.Vector3 {
        const pos = this.getRandomPosition().sub(this.origin);
        return pos.normalize();
    }
}
